package com.sky.controller.user;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sky.entity.Setmeal;
import com.sky.result.Result;
import com.sky.service.UserService;
import com.sky.vo.DishItemVO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

@RestController("usersetmealcontroller")
@RequestMapping("user/setmeal")
@Api(tags="套餐的菜品查询的相关接口")
@Slf4j

public class SetmealController {
	@Autowired
	private UserService userservice;
	@GetMapping("list")
	@ApiOperation("套餐接口")
	@Cacheable(cacheNames = "setmealCache",key = "#categoryId") //key: setmealCache::100
	public Result<List<Setmeal>> setmealList(Long categoryId)
	{
		log.info("套餐接口的参数:{}",categoryId);
		List<Setmeal> setmeal = userservice.setmealList(categoryId);
		return Result.success(setmeal);
	}
	/**
     * 根据套餐id查询包含的菜品列表
     *
     * @param id
     * @return
     */
    @GetMapping("/dish/{id}")
    @ApiOperation("根据套餐id查询包含的菜品列表")
    public Result<List<DishItemVO>> dishList(@PathVariable("id") Long id) {
        List<DishItemVO> list = userservice.getDishItemById(id);
        return Result.success(list);
    }
}
